<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<style>
.ui-datatable-scrollable-header-box {
	margin-left: 0px;
	margin-right: 15px !important;
}
</style>
	</ui:define>
	<ui:define name="content">
		<div class="box box-solid with-border">
			<div class="nav-tabs-custom" id="alarm1" style="position: relative">
				<ul class="nav nav-tabs pull-left">
					<li class="active"><a href="#scheduleShow" data-toggle="tab" onclick="refresh1()">节假日查看</a></li>
					<li><a href="#rotaPerson" data-toggle="tab" onclick="refresh()">节假日值班表</a></li>
					<li><a href="#holidayTab" data-toggle="tab" onclick="refresh()">节假日管理</a></li>
				</ul>
				<h:form>
					<p:remoteCommand name="refresh" update="form1 rotaPersonForm"
						oncomplete="getTableScrollHeight();"></p:remoteCommand>
					<p:remoteCommand name="refresh1" update="scheduleForm" oncomplete="resizeSlimScrollDiv()"></p:remoteCommand>
				</h:form>
				<div class="tab-content no-padding">
					<div id="scheduleShow" class="chart tab-pane active">
						<div class='full-center-content-scroll-noheader'>
							<h:form id="scheduleForm">
								<p:growl id="messages" showDetail="true" />
								<h:panelGrid columnClasses="value">
									<p:schedule id="schedule" value="#{holidayController.eventModel}" widgetVar="myschedule"
										timeZone="GMT+2" style="width:98%">
										<p:ajax event="eventSelect" listener="#{holidayController.onEventSelect}"
											update="eventDialog" oncomplete="PF('eventDialog').show();" />
									</p:schedule>
								</h:panelGrid>
								<p:dialog widgetVar="dateDialog" header="节日信息" showEffect="clip" hideEffect="clip">
									<p:dataTable id="dateHolidayTable" var="holiday"
										value="#{holidayController.selectDateHolidays}" widgetVar="holiday" style="width:600px;">
										<f:facet name="header">#{holidayController.selectDate}</f:facet>
										<p:column headerText="节日名称" groupRow="true" style="text-align:center; width:20%;">
											<p:outputLabel value="#{holiday.holidayName}" />
										</p:column>
										<p:column headerText="节日日期" style="text-align:center; width:30%;">
											<p:outputLabel value="#{holidayController.formatterDate(holiday.holiday)}" />
										</p:column>
										<p:column headerText="备注" style="text-align:left;width:50%;">
											<p:outputLabel value="#{holiday.remark}" />
										</p:column>
									</p:dataTable>
								</p:dialog>

								<p:dialog widgetVar="eventDialog" header="节日信息" modal="true" id="eventDialog" width="350"
									height="250">
									<p:toolbar id="toolBar" rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrck_bc')}">
										<f:facet name="left">
											<p:commandButton value="保存" icon="ui-icon-disk"
												actionListener="#{holidayController.editRotaPerson}"
												rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrck_bc')}"
												update="messages schedule toolBar :rotaPersonForm:rotaPersonTable"
												oncomplete="PF('eventDialog').hide()" />
										</f:facet>
									</p:toolbar>
									<p:outputPanel style="text-align:center; width:98%">
										<p:panelGrid columns="2">
											<h:outputText value="节日名称" />
											<p:inputText readonly="true" value="#{holidayController.selectDateHoliday.holidayName}" />
											<h:outputText value="节日日期" />
											<p:inputText readonly="true" value="#{holidayController.selectDate}" />
											<h:outputText value="节日备注" />
											<p:inputText readonly="true" value="#{holidayController.selectDateHoliday.remark}" />
											<h:outputText value="值班人" />
											<p:selectOneMenu id="rotaOrder" value="#{holidayController.rotaPersonIdAndName}"
												style="width:98%">
												<f:selectItem itemLabel="请选择" itemValue="" />
												<f:selectItems value="#{holidayController.rotaOrders}" />
											</p:selectOneMenu>
										</p:panelGrid>
									</p:outputPanel>
								</p:dialog>
							</h:form>
						</div>
					</div>
					<!-- rotaPerson table begin -->
					<div id="rotaPerson" class="chart tab-pane">
						<h:form id="rotaPersonForm">
							<p:confirmDialog global="true" showEffect="clip" hideEffect="clip">
								<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes"
									icon="ui-icon-check" />
								<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no"
									icon="ui-icon-close" />
							</p:confirmDialog>
							<p:growl id="rpmsgs" showDetail="true" />
							<p:toolbar id="toolbar"
								rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrzbb_xj') or
							s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrzbb_bj') or
							s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrzbb_sc')}">
								<f:facet name="left">
									<p:commandButton value="新建" icon="fa fa-plus"
										actionListener="#{holidayController.preCreateRotaPerson}"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrzbb_xj')}"
										oncomplete="PF('createRotaPersonDlg').show()" update="createRotaPersonDlg" />
									<p:commandButton value="编辑" icon="fa fa-pencil" id="editRpBtn"
										actionListener="#{holidayController.preEditRotaPerson}"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrzbb_bj')}"
										oncomplete="PF('createRotaPersonDlg').show()"
										disabled="#{holidayController.selectRotaPerson.id == null}"
										update="createRotaPersonDlg rotaPersonTable" />
									<p:commandButton value="删除" icon="fa fa-trash" id="deltRpBtn"
										update="rpmsgs rotaPersonTable editRpBtn deltRpBtn"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrzbb_sc')}"
										disabled="#{holidayController.selectRotaPerson.id == null}"
										actionListener="#{holidayController.deleteRotaPerson}">
										<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
									</p:commandButton>
								</f:facet>
							</p:toolbar>
							<p:dataTable id="rotaPersonTable" value="#{holidayController.rotaPersons}" var="rotaPerson"
								paginator="true" emptyMessage="无记录" rowKey="#{rotaPerson.id}" rows="20" rowIndexVar="ite"
								paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="20,50,100" paginatorPosition="bottom"
								style="text-align:center;margin-top:3px" scrollable="true">
								<f:facet name="{Customization}">
									<p:outputLabel value="总计：#{holidayController.rotaPersons.size()} 条记录"
										style="margin-right:20px;" />
								</f:facet>
								<p:ajax event="rowSelectRadio" update="rotaPersonForm"
									listener="#{holidayController.onRotaPersonSelect}" />
								<p:column selectionMode="single" width="5%" style="text-align:center" />
								<p:column width="5%" headerText="序号 ">
									<h:outputText value="#{ite+1}" />
								</p:column>
								<p:column headerText="用户Code">
									<p:outputLabel value="#{rotaPerson.personId}" />
								</p:column>
								<p:column headerText="姓名">
									<p:outputLabel value="#{rotaPerson.personName}" />
								</p:column>
								<p:column headerText="值班日期">
									<p:outputLabel value="#{holidayController.formatterDate(rotaPerson.rotaDate)}" />
								</p:column>
								<p:column headerText="节日名称">
									<p:outputLabel value="#{rotaPerson.remark}" />
								</p:column>
								<p:column headerText="年份">
									<p:outputLabel value="#{rotaPerson.year}" />
								</p:column>
							</p:dataTable>
							<p:dialog widgetVar="createRotaPersonDlg" header="值班人员信息" modal="true"
								id="createRotaPersonDlg" width="350" height="250">
								<p:toolbar id="saveToolbar">
									<f:facet name="left">
										<p:commandButton value="保存" icon="ui-icon-disk"
											actionListener="#{holidayController.saveRotaPerson}"
											update="rpmsgs rotaPersonTable toolbar createRotaPersonDlg"
											oncomplete="PF('createRotaPersonDlg').hide()" />
									</f:facet>
								</p:toolbar>
								<p:outputPanel style="text-align:center;">
									<p:panelGrid columns="2">
										<h:outputText value="当前值班人" />
										<p:inputText label="content" readonly="true"
											value="#{holidayController.rotaPerson.personName}" />
										<h:outputText value="备选值班人" />
										<p:selectOneMenu id="rotaOrder" value="#{holidayController.rotaOrder.personName}"
											style="width:98%">
											<f:selectItem itemLabel="请选择" itemValue="" />
											<f:selectItems value="#{holidayController.rotaOrders}" />
										</p:selectOneMenu>
										<h:outputText value="值班时间：" />
										<p:calendar id="date" navigator="true" value="#{holidayController.rotaPerson.rotaDate}"
											pattern="yyyy-MM-dd" />
										<h:outputText value="节日名称" />
										<!-- <p:inputText  value="#{holidayController.rotaPerson.remark}" /> -->
										<p:selectOneMenu id="console" value="#{holidayController.rotaPerson.remark}"
											style="width:98%">
											<f:selectItem itemLabel="请选择" itemValue="" />
											<f:selectItem itemLabel="元旦" itemValue="元旦" />
											<f:selectItem itemLabel="春节" itemValue="春节" />
											<f:selectItem itemLabel="清明节" itemValue="清明节" />
											<f:selectItem itemLabel="端午节" itemValue="端午节" />
											<f:selectItem itemLabel="劳动节" itemValue="劳动节" />
											<f:selectItem itemLabel="国庆节" itemValue="国庆节" />
											<f:selectItem itemLabel="中秋节" itemValue="中秋节" />
											<f:selectItem itemLabel="国庆中秋节" itemValue="国庆中秋节" />
										</p:selectOneMenu>
									</p:panelGrid>
								</p:outputPanel>
							</p:dialog>
						</h:form>
					</div>

					<!-- rotaPerson table end -->

					<div id="holidayTab" class="chart tab-pane">
						<h:form id="form1">
							<p:confirmDialog global="true" showEffect="clip" hideEffect="clip">
								<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes"
									icon="ui-icon-check" />
								<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no"
									icon="ui-icon-close" />
							</p:confirmDialog>
							<p:growl id="msgs" showDetail="true" />
							<p:toolbar id="toolBar"
								rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrgl_xj') or
							s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrgl_bj') or
							s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrgl_sc')}">
								<f:facet name="left">
									<p:commandButton value="新建" icon="fa fa-plus"
										actionListener="#{holidayController.preCreateHoliday}"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrgl_xj')}"
										oncomplete="PF('createDlg').show()" update="createDlg holidayTables" />
									<p:commandButton value="编辑" icon="fa fa-pencil" id="editBtn"
										actionListener="#{holidayController.editHoliday}"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrgl_bj')}"
										oncomplete="PF('editDlg').show()"
										disabled="#{holidayController.selectedHoliday.id == null}" update="editDlg holidayTables" />
									<p:commandButton value="删除" icon="fa fa-trash" id="deltBtn"
										update="msgs holidayTables editBtn deltBtn"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_jjrzb_jjrgl_sc')}"
										disabled="#{holidayController.selectedHoliday.id == null}"
										actionListener="#{holidayController.deleteHoliday}">
										<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
									</p:commandButton>
								</f:facet>
							</p:toolbar>
							<p:dataTable id="holidayTables" value="#{holidayController.holidays}" var="holidayItem"
								paginator="true" emptyMessage="无记录" rowKey="#{holidayItem.id}" rows="20" rowIndexVar="ite"
								paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="20,50,100" paginatorPosition="bottom"
								style="text-align:center;margin-top:3px" scrollable="true">
								<f:facet name="{Customization}">
									<p:outputLabel value="总计：#{holidayController.holidays.size()} 条记录"
										style="margin-right:20px;" />
								</f:facet>
								<p:ajax event="rowSelectRadio" update="form1:deltBtn form1:editBtn"
									listener="#{holidayController.onHolidaySelect}" />
								<p:column selectionMode="single" width="5%" style="text-align:center" />
								<p:column width="5%" headerText="序号 ">
									<h:outputText value="#{ite+1}" />
								</p:column>
								<p:column headerText="节假日名称" sortBy="#{holidayItem.holidayName}" style="width:20%">
									<p:outputLabel value="#{holidayItem.holidayName}" />
								</p:column>
								<p:column headerText="节假日日期" sortBy="#{holidayItem.holiday}" style="width:30%">
									<p:outputLabel value="#{holidayController.formatterDate(holidayItem.holiday)}" />
								</p:column>
								<p:column headerText="备注" style="text-align:left;margin-top:3px;width:40%;">
									<p:outputLabel value="#{holidayItem.remark}" />
								</p:column>
							</p:dataTable>
							<p:dialog widgetVar="createDlg" header="节假日信息" modal="true" id="createDlg" width="350"
								height="250">
								<p:toolbar>
									<f:facet name="left">
										<p:commandButton value="保存" icon="ui-icon-disk"
											actionListener="#{holidayController.saveHolidayInfo}"
											update="msgs holidayTables toolBar createDlg" oncomplete="PF('createDlg').hide()" />
									</f:facet>
								</p:toolbar>
								<p:outputPanel style="text-align:center;">
									<p:panelGrid columns="2">
										<h:outputText value="节假日名称" />
										<p:inputText label="content" value="#{holidayController.holidayName}" />
										<h:outputText value="节假日开始日期" />
										<p:calendar id="startdate" navigator="true" value="#{holidayController.holidayStartDate}"
											pattern="yyyy-MM-dd" />
										<h:outputText value="节假日结束日期" />
										<p:calendar id="enddate" navigator="true" value="#{holidayController.holidayEndDate}"
											pattern="yyyy-MM-dd" />
										<h:outputText value="备注" />
										<p:inputText label="content" value="#{holidayController.holidayRemark}" />
									</p:panelGrid>
								</p:outputPanel>
							</p:dialog>
							<p:dialog widgetVar="editDlg" header="节假日信息" modal="true" id="editDlg" width="350"
								height="250">
								<p:toolbar>
									<f:facet name="left">
										<p:commandButton value="保存" icon="ui-icon-disk"
											actionListener="#{holidayController.updateHolidayInfo}"
											update="msgs holidayTables toolBar deltBtn  editBtn" oncomplete="PF('editDlg').hide()" />
									</f:facet>
								</p:toolbar>
								<p:outputPanel style="text-align:center;">
									<p:panelGrid columns="2">
										<h:outputText value="节假日名称" />
										<p:inputText label="content" value="#{holidayController.holiday.holidayName}" />
										<h:outputText value="节假日日期" />
										<p:calendar id="date" navigator="true" value="#{holidayController.holiday.holiday}"
											pattern="yyyy-MM-dd" />
										<h:outputText value="备注" />
										<p:inputText label="content" value="#{holidayController.holiday.remark}" />
									</p:panelGrid>
								</p:outputPanel>
							</p:dialog>
						</h:form>
					</div>
				</div>
			</div>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/js/tables/tabScrollTable.js" />
		<script>
			var scheduleShowH = 0;
			jQuery(document).ready(function($) {
				scheduleShowH = parseInt($("#scheduleShow").css("height"));
				resizeSlimScrollDiv();
			});

			function resizeSlimScrollDiv() {
				var obj = $('.slimScrollDiv').each(function() {
					this.style.height = scheduleShowH - 50 + "px";
				});
			}
		</script>
	</ui:define>
</ui:composition>
